package com.example.demo.controller;
import com.example.demo.model.Js;
import com.example.demo.service.IJsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator 张喜英
 */

    @Api(tags = "js")
    @RestController
    @RequestMapping("/swagger6")
    public class JsController {
        @Autowired
        private IJsService jsService;
    @CrossOrigin
    @ApiOperation(value="对角色信息的添加方法")
    @PostMapping("/insertjs")
    public int insertJs(@RequestBody Js js){
        System.out.println("进入添加角色接口" );
        return jsService.insertJs(js);
    }

    @PostMapping("/getAll")
    public List<Js> getAllJs(@RequestBody Js js)
    {
        System.out.println("进入查询方法");
        List<Js> listJs=jsService.getAllJs(js);
        return listJs;
    }
    @PostMapping("/editJs")
    public int EditJs(@RequestBody Js js){
        System.out.println("添加修改方法");
        return jsService.updateJs(js);
}
    @GetMapping("/delJs")
    public int Delete(int jsid){
        System.out.println("进入删除方法");
        int returnValues=0;
        if(jsid!=0){
            Js js=new Js();
            js.setJsid(jsid);
        returnValues=jsService.deleteJs(js);
        }
        return returnValues;
    }

    @GetMapping("/getOne")
    public Js getJs(int jsid){
        Js js=new Js();
        System.out.println("进入单条查询方法");
        if(jsid!=0){
            Js js1=new Js();
            js1.setJsid(jsid);
            js=jsService.getJs(js1);
            System.out.println("返回的数据集合为:"+js.getJsid());
        }
        return js;
    }








}
